<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>
    <template id="t1">
      <div>
        <ul>
          <li v-for="hobby in hobbys">{{hobby}}</li>
        </ul>
      </div>
    </template>
    <script src="./vue.js"></script>
    <script>
      /*
        1. 为了保证数组响应式特性，操作数组一定要使用会修改原数组的方法
        2. 也可以整体覆盖赋值
        3. 对已有数据的修改编辑不会丢失响应式
      */
      const vm = new Vue({
        el: "#app",
        template: "#t1",
        data: {
          hobbys: ["css", "html", "js"],
        },
        created() {
          // this.hobbys.push("hello");
          setTimeout(() => {
            this.hobbys[3] = "hello";
          }, 3000);
          // this.hobbys[3] = "hello";
          // console.log(this.hobbys);
        },
        mounted() {
          // this.hobbys.push("hello");
          // console.log(this.hobbys);
        },
      });
    </script>
  </body>
</html>
